package cn.appinfodb.tools;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;


public class StringConvertDate implements Converter<String,Date> {

    private String pattern;

    public StringConvertDate(String pattern){
        this.pattern=pattern;
    }
    @Override
    public Date convert(String s) {

        Date date=null;
        try {
            date=new SimpleDateFormat(pattern).parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
}
